import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { OrderExtensionApi } from '#/api/spa/order/extension';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

import {DICT_SPA_TYPE} from "#/utils/dictSpa";
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'orderId',
      label: '关联trade_order表ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入关联trade_order表ID',
      },
    },
    {
      fieldName: 'appointmentStartTime',
      label: '预约开始时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'appointmentEndTime',
      label: '预约结束时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'actualStartTime',
      label: '实际开始时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'actualEndTime',
      label: '实际结束时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'serviceDuration',
      label: '服务时长(分钟)',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师ID',
      },
    },
    {
      fieldName: 'handCardId',
      label: '手牌ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入手牌ID',
      },
    },
    {
      fieldName: 'customerCount',
      label: '客户数量',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户数量',
      },
    },
    {
      fieldName: 'serviceRequirements',
      label: '服务要求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务要求',
      },
    },
    {
      fieldName: 'specialRequests',
      label: '特殊要求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入特殊要求',
      },
    },
    {
      fieldName: 'serviceStatus',
      label: '服务状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'serviceNotes',
      label: '服务备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务备注',
      },
    },
    {
      fieldName: 'customerNotes',
      label: '客户备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户备注',
      },
    },
    {
      fieldName: 'internalNotes',
      label: '内部备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入内部备注',
      },
    },
    {
      fieldName: 'interruptionReason',
      label: '中断原因',
      component: 'Input',
      componentProps: {
        placeholder: '请输入中断原因',
      },
    },
    {
      fieldName: 'interruptionHandling',
      label: '中断处理方案',
      component: 'Input',
      componentProps: {
        placeholder: '请输入中断处理方案',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限引用',
      },
    },
    {
      fieldName: 'serviceQualityChecklist',
      label: '服务质量检查清单',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务质量检查清单',
      },
    },
    {
      fieldName: 'technicianPerformanceNotes',
      label: '技师表现备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师表现备注',
      },
    },
    {
      fieldName: 'roomPreparationStatus',
      label: '房间准备状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'customerArrivalConfirmation',
      label: '客户到店确认',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'serviceStartConfirmation',
      label: '服务开始确认',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'serviceCompletionConfirmation',
      label: '服务完成确认',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'technicianGender',
      label: '技师性别要求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师性别要求',
      },
    },
    {
      fieldName: 'roomType',
      label: '房间类型要求',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择房间类型要求',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'orderId',
      label: '关联trade_order表ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入关联trade_order表ID',
      },
    },
    {
      fieldName: 'appointmentStartTime',
      label: '预约开始时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'appointmentEndTime',
      label: '预约结束时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'actualStartTime',
      label: '实际开始时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'actualEndTime',
      label: '实际结束时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'serviceDuration',
      label: '服务时长(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师ID',
      },
    },
    {
      fieldName: 'handCardId',
      label: '手牌ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入手牌ID',
      },
    },
    {
      fieldName: 'customerCount',
      label: '客户数量',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户数量',
      },
    },
    {
      fieldName: 'serviceRequirements',
      label: '服务要求',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务要求',
      },
    },
    {
      fieldName: 'specialRequests',
      label: '特殊要求',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入特殊要求',
      },
    },
    {
      fieldName: 'serviceStatus',
      label: '服务状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择服务状态',
      },
    },
    {
      fieldName: 'serviceNotes',
      label: '服务备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务备注',
      },
    },
    {
      fieldName: 'customerNotes',
      label: '客户备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户备注',
      },
    },
    {
      fieldName: 'internalNotes',
      label: '内部备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入内部备注',
      },
    },
    {
      fieldName: 'interruptionReason',
      label: '中断原因',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入中断原因',
      },
    },
    {
      fieldName: 'interruptionHandling',
      label: '中断处理方案',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入中断处理方案',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限引用',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'serviceQualityChecklist',
      label: '服务质量检查清单',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务质量检查清单',
      },
    },
    {
      fieldName: 'technicianPerformanceNotes',
      label: '技师表现备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师表现备注',
      },
    },
    {
      fieldName: 'roomPreparationStatus',
      label: '房间准备状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择房间准备状态',
      },
    },
    {
      fieldName: 'customerArrivalConfirmation',
      label: '客户到店确认',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择客户到店确认',
      },
    },
    {
      fieldName: 'serviceStartConfirmation',
      label: '服务开始确认',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择服务开始确认',
      },
    },
    {
      fieldName: 'serviceCompletionConfirmation',
      label: '服务完成确认',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择服务完成确认',
      },
    },
    {
      fieldName: 'technicianGender',
      label: '技师性别要求',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师性别要求',
      },
    },
    {
      fieldName: 'roomType',
      label: '房间类型要求',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择房间类型要求',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<OrderExtensionApi.OrderExtension>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,

    },
    {
      field: 'orderId',
      title: '关联trade_order表ID',
      minWidth: 120,

    },
    {
      field: 'appointmentStartTime',
      title: '预约开始时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'appointmentEndTime',
      title: '预约结束时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'actualStartTime',
      title: '实际开始时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'actualEndTime',
      title: '实际结束时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'serviceDuration',
      title: '服务时长(分钟)',
      minWidth: 120,

    },
    {
      field: 'roomId',
      title: '房间ID',
      minWidth: 120,

    },
    {
      field: 'technicianId',
      title: '技师ID',
      minWidth: 120,

    },
    {
      field: 'handCardId',
      title: '手牌ID',
      minWidth: 120,

    },
    {
      field: 'customerCount',
      title: '客户数量',
      minWidth: 120,

    },
    {
      field: 'serviceRequirements',
      title: '服务要求',
      minWidth: 120,

    },
    {
      field: 'specialRequests',
      title: '特殊要求',
      minWidth: 120,

    },
    {
      field: 'serviceStatus',
      title: '服务状态',
      minWidth: 120,

    },
    {
      field: 'serviceNotes',
      title: '服务备注',
      minWidth: 120,

    },
    {
      field: 'customerNotes',
      title: '客户备注',
      minWidth: 120,

    },
    {
      field: 'internalNotes',
      title: '内部备注',
      minWidth: 120,

    },
    {
      field: 'interruptionReason',
      title: '中断原因',
      minWidth: 120,

    },
    {
      field: 'interruptionHandling',
      title: '中断处理方案',
      minWidth: 120,

    },
    {
      field: 'scope',
      title: '权限范围',
      minWidth: 120,

    },
    {
      field: 'scoperef',
      title: '权限引用',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'serviceQualityChecklist',
      title: '服务质量检查清单',
      minWidth: 120,

    },
    {
      field: 'technicianPerformanceNotes',
      title: '技师表现备注',
      minWidth: 120,

    },
    {
      field: 'roomPreparationStatus',
      title: '房间准备状态',
      minWidth: 120,

    },
    {
      field: 'customerArrivalConfirmation',
      title: '客户到店确认',
      minWidth: 120,

    },
    {
      field: 'serviceStartConfirmation',
      title: '服务开始确认',
      minWidth: 120,

    },
    {
      field: 'serviceCompletionConfirmation',
      title: '服务完成确认',
      minWidth: 120,

    },
    {
      field: 'technicianGender',
      title: '技师性别要求',
      minWidth: 120,

    },
    {
      field: 'roomType',
      title: '房间类型要求',
      minWidth: 120,

    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

